package com.example.test.service;

import com.example.test.dao.UserMapper;
import com.example.test.pojo.User;
import com.example.test.vo.UserVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public UserVo getUserInfo(Integer userId) {
        User user = userMapper.selectByPrimaryKey(userId);
        UserVo userVo = new UserVo();
        // 第一个参数是被复制的对象,将user对象的属性值复制到userVo中
        BeanUtils.copyProperties(user, userVo);
        return userVo;
    }
}
